package day1_12.FirstPhase;

import java.util.Random;
// 需求: 写一个生成随机验证码的程序,验证码包括26个字母大小写和0-9数字
// 半成品,前四位是字母,最后一位是数字
public class VerifyCode {
    public static void main(String[] args) {
        char[] code = new char[52];
        for (int i = 0; i < code.length; i++) {
            if (i < 26) {
                code[i] = (char) ('a' + i);
            }else {
                code[i] = (char) ('A' + i - 26);
            }

        }
//        遍历
//        for (int i = 0; i < code.length; i++) {
//            System.out.print(code[i] + " ");
//        }

        String codeString = "";
        for (int i = 0; i < 4; i++) {
            Random r = new Random();
            int randomNum = r.nextInt(code.length);
            codeString += code[randomNum];
        }
        Random r = new Random();
        int number = r.nextInt(10);
        codeString += number;
        System.out.println(codeString);

    }
}
